package main

import (
	"fmt"
	"strings"
)

func main() {
	example :=[]string{"acabcddd","bcbdbcbd","baddbadb","cbdddcac","aacbcccd","ccccddda","cababaab","addcaccd"}
	result := commonChars(example)
	fmt.Print(result)
}

func commonChars(A []string) []string {
	char_map := make(map[int32]int)
	for _,ch := range A[0] {
		char_map[ch] = strings.Count(A[0], string(ch))
	}
	for i:=1;i<len(A);i++{
		for _,ch := range A[0] {
			n:=strings.Count(A[i], string(ch))
			if char_map[ch]>n{
				char_map[ch]=n
			}
		}
	}
	result := []string{}
	for ch,n := range char_map{
		for i:=0;i<n;i++{
			result=append(result, string(ch))
		}
	}
	return result
}